package models.common.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Transient;

import play.db.jpa.Model;

import common.constants.ConfConst;
import common.constants.Constants;
import common.utils.Security;


/**
 * 账款推送关系表
 *@author liangQiongfeng
 *@version 2018-1-10 下午5:54:19
 */
@Entity
public class t_receivables_push extends Model{
	
	/**推送时间*/
	public Date time;
	
	/**放款人*/
	public long lender_id;
	
	/**融通人*/
	public long user_id;
	
	/**账款id*/
	public long creditor_right_id;
	
	/**状态 0 默认 1 推送中 2 已确认 3 退回'*/
	public int status;

	/**授信申请表id*/
	public long credit_limit_id;
	
	/**
	 * 获取账款推送状态
	 * @return the status
	 */
	public Status getStatus() {
		Status status = Status.getEnum(this.status);
		return status;
	}
	
	/**
	 * 状态枚举
	 * @description
	 *
	 * @author ChenZhipeng
	 * @createDate 2015年12月21日
	 */
	public enum Status {
		/** 0:默认 */
		FAILED(0, "失败"),

		/** 1-推送中 */
		PUSHING(1, "推送中"),
		
		/** 2-已确认 */
		CONFIRMED(2, "已确认"),
		
		/**3-退回*/
		RETURN(3, "退回");

		public int code;
		public String value;

		private Status(int code, String value) {
			this.code = code;
			this.value = value;
		}

		public static Status getEnum(int code) {
			Status[] status = Status.values();
			for (Status stat : status) {
				if (stat.code == code) {

					return stat;
				}
			}

			return null;
		}
	}
	
	/**加密ID*/
	@Transient
	public String sign;
	
    public String getSign () {
		return Security.addSign(this.id, Constants.BID_ID_SIGN, ConfConst.ENCRYPTION_KEY_DES);
	}
	
}
